﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Share.Models;
using Share.Utils;

namespace Admin.Controllers
{
    public class IncludeController : Controller
    {
        //
        // GET: /Include/SelectCategory

        public ActionResult SelectCategory(int parentId=0)
        {
            IEnumerable<Category> m;

            if (parentId == 0)
                m = DB.Current.Categories.Where(c => c.ParentCategory == null).ToList();
            else
                m = DB.Current.Categories.Find(parentId).SubCategories.ToList();

            return View(CategoryUtil.CategoryTreeList(m));
        }
    }
}
